#!/bin/bash
#
read -p "输入服务名称：" data

if ! ps -elf | grep "$data" | grep -v "grep" &> /dev/null; then
   echo "进程${data}没有启动"
else
   pid=$(pidof $data)
   port=$(netstat -tunlp | grep "$data" | awk '{print $4}' | awk -F: '{print $4}' | xargs)
   starttime=$(ps -p "$pid" -o lstart= 2> /dev/null)
   echo "服务名称: $data  PID: $pid  端口: $port  启动时间: $starttime"
fi

